package com.team7.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.team7.common.entity.Teacher;
import com.team7.common.vo.CommonResult;
import com.team7.dao.TeacherOrderDao;
import com.team7.service.TeacherOrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @program: team7-Object02
 * @description: 订单讲师实现类
 * @author: 王子鑫
 * @create: 2021-10-22 16:11
 **/
@Service
public class TeacherOrderImpl implements TeacherOrderService {
    @Resource
    private TeacherOrderDao teacherOrderDao;


    @Override
    public CommonResult findTeacherByName(String teacherName) {
        Teacher teacherByName = teacherOrderDao.findTeacherByName(teacherName);
        return new CommonResult(2000,"查询成功",teacherByName);
    }

    @Override
    public CommonResult findTeacherBYMobile(String mobile) {
        QueryWrapper<Teacher> wrapper = new QueryWrapper<>();
        wrapper.eq("mobile",mobile);
        Teacher teacher = teacherOrderDao.selectOne(wrapper);
        if (teacher!=null){
            return new CommonResult(2000,"查询成功",teacher);
        }else {
            return new CommonResult(5000,"查询失败",null);
        }
    }

    @Override
    public CommonResult updateTeacherBYMobile(Teacher teacher) {
        int i = teacherOrderDao.updateById(teacher);
        if (i>0){
            return new CommonResult(2000,"修改成功",null);
        }else {
            return new CommonResult(5000,"修改失败",null);
        }
    }
}
